package rsj.api.report;

import com.rlyy.aibase.utils.base.Box;
import common.util.BoxUtil;
import common.util.validator.ParameterConversionCheck;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import rsj.api.report.entity.AccountReport;
import rsj.api.report.entity.AccountReportDetail;
import rsj.api.report.entity.ReportParam;
import rsj.service.report.IReportService;

import javax.validation.groups.Default;
import java.util.List;

/**
 * 账号报表
 *
 * @author yuanqinglong
 * @since 2021/7/21 17:58
 */
@RestController
public class AccountReportController {


    @Autowired
    private IReportService<AccountReport, AccountReportDetail, ReportParam> accountReportServiceImpl;


    /**
     * 账号报告列表
     *
     * @param param 参数
     * @return {@link Box}
     */
    @RequestMapping(value = "rsj_report_account_list")
    public Box reportList(Box param) {
        ReportParam reportParam = ParameterConversionCheck.parameterConversionCheckFastFail(param, ReportParam.class, ReportParam.Table.class, Default.class);
        List<AccountReport> accountReportResults = accountReportServiceImpl.reportList(reportParam);
        int count = accountReportServiceImpl.reportCount(reportParam);
        return BoxUtil.successBoxToTableData(param, accountReportResults, count);
    }


    /**
     * 账号详细的列表
     *
     * @param param 参数
     * @return {@link Box}
     */
    @RequestMapping(value = "rsj_report_account_detail_list")
    public Box detailList(Box param) {
        ReportParam reportParam = ParameterConversionCheck.parameterConversionCheckFastFail(param, ReportParam.class,
                ReportParam.Table.class, ReportParam.AutKeyid.class, Default.class);
        List<AccountReportDetail> accountReportDetails = accountReportServiceImpl.detailList(reportParam);
        int count = accountReportServiceImpl.detailCount(reportParam);
        return BoxUtil.successBoxToTableData(param, accountReportDetails, count);
    }

}
